package com.example.util;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;

/**
 * HttpServletResponse甯姪锟�
 */
public class ResponseUtils {
	public static Object outputJson(HttpServletResponse response, Object obj,JsonConfig jsonConfig) {
			JSONArray userjson = JSONArray.fromObject(obj,jsonConfig);
			return userjson.get(0);
	}
	
	public static void outh5putJson(HttpServletResponse response, Object obj,JsonConfig jsonConfig) {
		response.setCharacterEncoding("utf-8");
		PrintWriter out;
		try {
			out = response.getWriter();
			Gson gson = new Gson();
			out.println(gson.toJson(obj));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
